package com.why.controller;

import com.why.pojo.User;
import com.why.service.UserService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController {

    /**
     * 1.从zookeeper注册中心获取userService的访问url
     * 2.远程的调用RPC
     * 3.将结果封装为代理的对象，给变量赋值
     */
    @Reference //远程注入
    private UserService userService;

    @RequestMapping("/sayHello")
    public String sayHello() {
        return userService.say();
    }

    @RequestMapping("/find")
    public User find(int id) {
        return userService.findUserById(id);
    }


}
